package Lab07;

import java.util.Scanner;

public class Triangle extends GeometricObject {
    private double side1, side2, side3;

    public Triangle() {
        super();
        side1 = side2 = side3 = 1.0;
    }

    public Triangle(double side1, double side2, double side3) {
        super();
        this.side1 = side1;
        this.side2 = side2;
        this.side3 = side3;
    }

    double getArea() {
        double s = (side1 + side2 + side3) / 2;
        return Math.sqrt(s * (s - side1) * (s - side2) * (s - side3));
    }

    double getPerimeter() {
        return side1 + side2 + side3;
    }


    @Override
    public String toString() {
        return "Triangle: side1 = " + side1 + " side2 = " + side2 + " side3 = " + side3;
    }

    public double getSide1() {
        return side1;
    }

    public void setSide1(double side1) {
        this.side1 = side1;
    }

    public double getSide2() {
        return side2;
    }

    public void setSide2(double side2) {
        this.side2 = side2;
    }

    public double getSide3() {
        return side3;
    }

    public void setSide3(double side3) {
        this.side3 = side3;
    }
}

class TestTriangle {
    public static void main(String[] args) {
//        Write a test program that prompts the user to enter three sides of the triangle, a color,
//        and a Boolean value to indicate whether the triangle is filled.
        Scanner scanner = new Scanner(System.in);
        System.out.print("Enter three sides:");
        double side1 = scanner.nextDouble();
        double side2 = scanner.nextDouble();
        double side3 = scanner.nextDouble();
        System.out.print("Enter the color:");
        String color = scanner.next();
        System.out.print("Enter a boolean value for filled:");
        boolean isFilled = scanner.nextBoolean();
        scanner.close();
        Triangle triangle = new Triangle(side1, side2, side3);
        triangle.setColor(color);
        triangle.setFilled(isFilled);
        System.out.println(triangle);
        System.out.println("The area is " + triangle.getArea());
        System.out.println("The perimeter is " + triangle.getPerimeter());
        System.out.println("The color is " + triangle.getColor());
        System.out.println("Is it filled? " + triangle.isFilled());
    }
}